var t, o = require("../../../../@babel/runtime/helpers/defineProperty"), e = getApp();

Component({
    properties: {
        ipnonexbol: {
            type: null
        },
        goodsType: {
            type: null
        },
        goods_plugin: {
            type: null
        },
        activityid: {
            type: null
        },
        isBegTime: {
            type: null
        },
        isRent: {
            type: null
        },
        isTime: {
            type: null
        },
        beginDownObj: {
            type: null
        },
        goodsId: {
            type: Number
        },
        enterAt: {
            type: Object
        },
        goodsInfo: {
            type: null
        },
        isTimeEnd: {
            type: null
        },
        leader_partake: {
            type: null
        },
        leader_not_join_invalid: {
            type: null
        },
        mode: {
            type: null
        },
        cart_num: {
            type: null
        },
        debtId: {
            type: null
        },
        MachineId: {
            type: null
        }
    },
    data: {
        tiktok_popup: !1,
        posterShow: !1,
        isDisabled: !1,
        group_price: "",
        service_mobile: "",
        service_QRcode: "",
        customer_open: !1,
        show1: !1,
        isAddCart: !1,
        SUBMIT_ACTION_CART: "-1",
        SUBMIT_ACTION_BUY: "-2",
        specsManage: [],
        goodsCount: 1,
        language: "",
        beginDownObj: {
            day: "00",
            hou: "00",
            min: "00",
            sec: "00"
        },
        is_yz_supplyGoods: !1,
        gooddatas: [],
        nocart: !1,
        isBuy: !1,
        goods_info: [],
        timestamp: Date.parse(new Date()) / 1e3,
        checkSetTimeOut: "",
        isShowShop: !0,
        AdressState: "1",
        supplierListShow: !1
    },
    observers: {
        "goodsInfo,goodsType": function(t, o) {
            "group_goods" != o && "grabGroup" != o && "ywmGroup" != o && (this.setIsAddCart(), 
            "hotelGoods" == o && this.isFavorite(), 140 == (null == t ? void 0 : t.plugin_id) && this.setSupplyGoodsData(), 
            t.supplier && 0 == Number(t.supplier.is_open) && this.setData({
                isShowShop: !1
            }));
        },
        isRent: function(t) {},
        gooddatas: function(t) {}
    },
    lifetimes: {
        attached: function() {
            var t = wx.getStorageSync("langIndex");
            this.setData({
                language: t.en
            }), this.setSupplyGoodsData();
        },
        ready: function() {
            "zhpGroup" == this.data.goodsType && this.checkSet(), this.setGoodBuyDisabled(), 
            this.data.MachineId && this.setData({
                nocart: !0
            });
        },
        detached: function() {
            "zhpGroup" == this.data.goodsType && clearInterval(this.data.checkSetTimeOut);
        }
    },
    methods: (t = {
        toMyGroups: function() {
            wx.navigateTo({
                url: "/packageB/member/group/MyGroups/MyGroups"
            });
        },
        childAdressPost: function(t) {
            console.log(t, "eeeeeeeechildAdressPost"), this.setData({
                AdressState: t
            });
        },
        closeShopList: function() {
            this.setData({
                supplierListShow: !1
            });
        },
        setGoodBuyDisabled: function() {
            var t = this.data.goods_plugin;
            t && t.month_buy_limit && t.month_buy_limit != [] && t.month_buy_limit.hasOwnProperty("can_buy") && this.setData({
                isDisabled: !t.month_buy_limit.can_buy
            });
        },
        setSupplyGoodsData: function() {
            var t, o = wx.getStorageSync("yz_basic_info").plugin_setting;
            o && o.yz_supply_camilo_resources && (1 === o.yz_supply_camilo_resources.is_ios_sell || "1" === o.yz_supply_camilo_resources.is_ios_sell) && ("ios" == wx.getSystemInfoSync().platform && 140 == (null === (t = this.data.goodsInfo) || void 0 === t ? void 0 : t.plugin_id) && this.setData({
                is_yz_supplyGoods: !0
            }));
        },
        originalPriceTo: function(t) {
            var o = t.currentTarget.dataset.gid;
            wx.navigateTo({
                url: "/packageA/detail_v2/detail_v2?id=" + o
            });
        },
        gotoChat: function(t) {
            var o = t.currentTarget.dataset.cservice + "&goods_id=" + this.data.goodsId;
            console.log(o), wx.navigateTo({
                url: o,
                fail: function(t) {
                    e.tips("客服路由出错");
                }
            });
        },
        gotoCart1: function() {
            wx.reLaunch({
                url: "/packageG/pages/buy/cart_v2/cart_v2"
            });
        },
        gotoindex: function() {
            wx.reLaunch({
                url: "/packageG/index/index"
            });
        },
        tapkefu: function() {
            this.setData({
                kefu: !0
            });
        },
        closePop: function() {
            this.setData({
                show1: !1
            });
        },
        showPop: function() {
            console.log("执行");
            var t = e._isTextEmpty(this.data.service_mobile) && e._isTextEmpty(this.data.service_QRcode);
            if (e._isTextEmpty(this.data.cservice) && t) return e.tips("抱歉，暂未设置客服信息");
            e._isTextEmpty(this.data.cservice) || !t ? this.setData({
                show1: !0
            }) : this.gotoChat({
                currentTarget: {
                    dataset: {
                        cservice: this.data.cservice
                    }
                }
            });
        },
        callPhone: function() {
            wx.makePhoneCall({
                phoneNumber: this.data.service_mobile
            });
        },
        setIsAddCart: function() {
            (e._isTextEmpty(this.data.goodsInfo.buy_way) || "0" == this.data.goodsInfo.buy_way) && this.setData({
                isAddCart: !0
            }), 1 == this.data.goodsInfo.buy_way && this.setData({
                isAddCart: !1
            });
        },
        addCart: function() {
            var t = this;
            if (this.data.isAddCart) if (this.data.goodsInfo.vip_level_status && 1 == this.data.goodsInfo.vip_level_status.status) wx.showToast({
                icon: "none",
                title: this.data.goodsInfo.vip_level_status.tips,
                duration: 2500
            }); else {
                var o = e.getNetAddresss("member.member.isValidatePageGoods");
                e._getNetWork({
                    showToastIn: !1,
                    url: o,
                    success: function(o) {
                        var e = o.data;
                        if (1 == e.result) {
                            if (t.data.goodsInfo.has_one_invite_page && 1 === t.data.goodsInfo.has_one_invite_page.status && 0 === e.data.is_invite) return void wx.navigateTo({
                                url: "/packageC/member/visit/Inviter/Inviter?fromGood=1"
                            });
                            t.setData({
                                submitActionTag: t.data.SUBMIT_ACTION_CART
                            }), t.triggerEvent("popupModeshowChild", {
                                submitActionTag: t.data.SUBMIT_ACTION_CART
                            }), 1 == t.data.goodsInfo.has_option ? (console.log("1111111111111111111", t.data.optionsId), 
                            t.triggerEvent("popupModeshowChild", {
                                popupSpecs: !0,
                                popupModeshow: !1,
                                submitActionTag: t.data.SUBMIT_ACTION_CART
                            })) : (console.log("1111111111111111111加入购物车操作，无规格"), t.setData({
                                optionsId: ""
                            }), t.data.isAddCart && (console.log(t.data.SUBMIT_ACTION_CART), t.triggerEvent("popupModeshowChild", {
                                popupSpecs2: !0,
                                popupModeshow: !1,
                                submitActionTag: t.data.SUBMIT_ACTION_CART,
                                isAddCart: t.data.isAddCart
                            })));
                        } else wx.showToast({
                            icon: "none",
                            title: e.msg,
                            duration: 2500
                        });
                    }
                });
            }
        },
        addCartRequest: function(t, o, s) {
            if (0 != this.data.optionsMaxCount) {
                if (s <= 0) return this.setData({
                    popupSpecs: !1,
                    popupModeshow: !0
                }), void wx.showToast({
                    icon: "none",
                    title: "请选择商品数量",
                    duration: 2500
                });
                var a = this, i = [];
                i.push(t);
                var n = e.getNetAddresss("from.div-from.isDisplay");
                n += "&goods_ids=" + JSON.stringify(i), e._getNetWork({
                    showToastIn: !1,
                    url: n,
                    success: function(e) {
                        var i = e.data;
                        1 == i.result ? i.data.status && !i.data.member_status ? wx.showModal({
                            title: "提示",
                            content: "购买此商品,请补充您的个人信息",
                            success: function(t) {
                                t.confirm ? wx.navigateTo({
                                    url: "/packageB/member/address/myinfo/myinfo?tag=delta"
                                }) : t.cancel && console.log("用户点击取消");
                            }
                        }) : a.addCartReq(t, o, s) : wx.showToast({
                            icon: "none",
                            title: i.msg,
                            duration: 2500
                        });
                    },
                    fail: function(t) {}
                });
            } else wx.showToast({
                icon: "none",
                title: "商品库存不足",
                duration: 2500
            });
        },
        addCartReq: function(t, o, s) {
            var a = this, i = e.getNetAddresss("member.member-cart.store");
            i += "&goods_id=" + t, i += "&total=" + s, i += "&option_id=" + o, e._getNetWork({
                showToastIn: !1,
                url: i,
                success: function(t) {
                    var o = t.data;
                    1 == o.result ? (e.globalData.cart_num = o.data.cart_num, a.triggerEvent("changeCartNumber", o.data.cart_num), 
                    wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 2500
                    })) : wx.showToast({
                        icon: "none",
                        title: o.msg,
                        duration: 2500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        toWarning: function() {
            var t = this;
            wx.showModal({
                title: "提示",
                content: "因平台规则限制，IOS端不支持购买虚拟商品；如需帮助，请联系客服。",
                confirmText: "联系客服",
                success: function(o) {
                    o.confirm ? t.showPop() : o.cancel && console.log("用户点击取消");
                }
            });
        },
        buyNow: function(t) {
            if (this.data.is_yz_supplyGoods) this.toWarning(); else if (!this.data.isDisabled) {
                var o = t || !1, s = this;
                if (this.data.isBuy && this.data.isBegTime) return wx.showToast({
                    icon: "none",
                    title: "该商品还没到购买时间",
                    duration: 2500
                }), !1;
                if (this.data.goodsInfo.vip_level_status && 1 == this.data.goodsInfo.vip_level_status.status) wx.showToast({
                    icon: "none",
                    title: this.data.goodsInfo.vip_level_status.tips,
                    duration: 2500
                }); else {
                    var a = e.getNetAddresss("member.member.isValidatePageGoods");
                    e._getNetWork({
                        showToastIn: !1,
                        url: a,
                        success: function(t) {
                            var e = t.data;
                            if (1 == e.result) {
                                if (s.data.goodsInfo.has_one_invite_page && 1 === s.data.goodsInfo.has_one_invite_page.status && 0 === e.data.is_invite) return void wx.navigateTo({
                                    url: "/packageC/member/visit/Inviter/Inviter?fromGood=1"
                                });
                                s.setData({
                                    submitActionTag: s.data.SUBMIT_ACTION_BUY
                                }), console.log(s.data.SUBMIT_ACTION_BUY), s.triggerEvent("buyNowFoot", {
                                    submitActionTag: s.data.SUBMIT_ACTION_BUY,
                                    submitTag: o
                                }), 1 == s.data.goodsInfo.has_option ? (s.setData({
                                    popupSpecs: !0,
                                    popupModeshow: !1
                                }), s.triggerEvent("buyNowFoot", {
                                    popupSpecs: !0,
                                    popupModeshow: !1,
                                    submitActionTag: s.data.SUBMIT_ACTION_BUY,
                                    submitTag: o
                                })) : 0 == s.data.goodsInfo.has_option && s.showPopView2();
                            } else wx.showToast({
                                icon: "none",
                                title: e.msg,
                                duration: 2500
                            });
                        }
                    });
                }
            }
        },
        showPopView: function(t) {
            var o = t.currentTarget.dataset.type;
            this.triggerEvent("buyNowFoot", {
                isAward: o,
                popupSpecs: !0,
                popupModeshow: !1
            });
        },
        showPopView2: function(t) {
            this.triggerEvent("buyNowFoot", {
                popupSpecs2: !0,
                popupModeshow: !1,
                submitActionTag: this.data.SUBMIT_ACTION_BUY
            });
        },
        onFavorite: function(t) {
            t.currentTarget.dataset.fadata ? this.removeFavorite() : this.addFavorite();
        },
        isFavorite: function() {
            var t = this, o = e.getNetAddresss("member.member-favorite.isFavorite");
            o += "&goods_id=" + this.data.goodsId, e._getNetWork({
                url: o,
                success: function(o) {
                    var e = o.data;
                    1 == e.result && t.setData({
                        favorite: 1 == e.data.status
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        removeFavorite: function() {
            var t = this, o = e.getNetAddresss("member.member-favorite.destroy");
            o += "&goods_id=" + this.data.goodsId, e._getNetWork({
                url: o,
                success: function(o) {
                    1 == o.data.result && (t.setData({
                        favorite: !1
                    }), wx.showToast({
                        icon: "none",
                        title: "操作成功",
                        duration: 2500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        addFavorite: function() {
            var t = this, o = e.getNetAddresss("member.member-favorite.store");
            o += "&goods_id=" + this.data.goodsId, e._getNetWork({
                url: o,
                success: function(o) {
                    1 == o.data.result && (t.setData({
                        favorite: !0
                    }), wx.showToast({
                        icon: "none",
                        title: "操作成功",
                        duration: 2500
                    }));
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        },
        order: function() {
            var t = this.data.goods_info.get_hotel_info.goods.hotel_id, o = this.data.enterAt ? this.data.enterAt.end : "", e = this.data.enterAt ? this.data.enterAt.start : "";
            wx.navigateTo({
                url: "/packageA/hotel/HotelGoodsOrder/HotelGoodsOrder?end=" + o + "&start=" + e + "&id=" + t + "&goods_id=" + this.data.goodsId
            });
        }
    }, o(t, "closeShopList", function() {
        this.setData({
            supplierListShow: !1
        });
    }), o(t, "gotoHome", function(t) {
        var o = t.currentTarget.dataset.str;
        if ("zhplis" == o) return console.log("珍惠拼 拼团列表"), void wx.navigateTo({
            url: "/packageB/member/group/MyGroups/MyGroups?types=zhpGroup"
        });
        "supplier" == o && this.data.goodsInfo.supplier ? this.setData({
            supplierListShow: !0
        }) : this.data.MachineId ? wx.reLaunch({
            url: "/packageI/vending_machine/vending_machine?id=" + this.data.MachineId
        }) : wx.reLaunch({
            url: "/packageG/index/index"
        });
    }), o(t, "showGroupMore", function() {
        this.triggerEvent("showGroupMoreChild");
    }), o(t, "openCardGroup", function() {
        this.triggerEvent("buyNowFoot", {
            popupSpecs: !0,
            popupModeshow: !1,
            submitActionTag: "openCardGroup"
        });
    }), o(t, "tapshowOne", function() {
        this.triggerEvent("buyNowFoot", {
            popupSpecs: !0,
            popupModeshow: !1,
            submitActionTag: "-2"
        });
    }), o(t, "buyNowRetail", function(t) {
        var o = t.currentTarget.dataset.buytype;
        1 == this.data.goodsInfo.has_option ? (this.setData({
            popupSpecs: !0,
            popupModeshow: !1
        }), this.triggerEvent("buyNowRetail", {
            popupSpecs: !0,
            popupModeshow: !1,
            buyType: o
        })) : 0 == this.data.goodsInfo.has_option && this.showPopVie(o);
    }), o(t, "showPopVie", function(t) {
        this.triggerEvent("buyNowRetail", {
            popupSpecs2: !0,
            popupModeshow: !1,
            buyType: t
        });
    }), o(t, "zhpGroupTap", function(t) {
        if (console.log(t), "zhpyh" != t.currentTarget.dataset.buytype) {
            1 == this.data.goodsInfo.has_option ? (this.setData({
                popupSpecs: !0,
                popupModeshow: !1
            }), this.triggerEvent("buyNowFoot", {
                popupSpecs: !0,
                popupModeshow: !1,
                submitActionTag: this.data.SUBMIT_ACTION_BUY,
                optionsId: this.data.gooddatas.has_many_options[0].option_id
            })) : 0 == this.data.goodsInfo.has_option && this.showPopView2();
        } else wx.navigateTo({
            url: "/packageB/member/group/MyGroups/MyGroups?tag=1&types=zhpGroup"
        });
    }), o(t, "checkSet", function(t) {
        var o = this, e = this, s = this.data.timestamp;
        e.setData({
            timeset: !1
        }), this.data.checkSetTimeOut = setInterval(function() {
            2 == o.data.gooddatas.status && (e.setData({
                timeset: !0
            }), clearInterval(o.data.checkSetTimeOut)), s <= e.data.gooddatas.start_time ? e.setData({
                timeset: !0
            }) : s <= e.data.gooddatas.end_time && (e.setData({
                timeset: !1
            }), clearInterval(o.data.checkSetTimeOut));
        }, 1e3);
    }), t)
});